package com.xzy.spring.main;

import com.xzy.spring.config.ProfileConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @author xzy
 * @date 2021-02-14 20:48
 * 说明：
 */
public class ProfileMain {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext();

        // 设置运行环境：dev、test、prod......
        ConfigurableEnvironment environment = annotationConfigApplicationContext.getEnvironment();
        environment.setActiveProfiles("dev");
        annotationConfigApplicationContext.register(ProfileConfig.class);
        annotationConfigApplicationContext.refresh();

        for (String beanDefinitionName : annotationConfigApplicationContext.getBeanDefinitionNames()) {
            System.out.println(beanDefinitionName);
        }
    }
}
